home *** CD-ROM | disk | FTP | other *** search
- -- AMBERVISION "ripple" effects --
-
- on grabberInit
- global oGrabber, gRippleSize, gCPU, gHorsepower
-
- -- --Open the stageToPICT XObject
- -- if objectP(oGrabber) then oGrabber(mDispose) --Trash any old versions of screen-grabber
-
- --If the game has 6Meg available, use small ripple; 8Meg for large; less than 6Meg, skip it
- set totalRAM = the memorySize/1024 --expressed in kilobytes
- -- PUT "total RAM available to the game = "& totalRAM &" K"
-
- if totalRAM >= 8000 AND (gHorsepower <> #low) then
- preloadCast 2428, 2451
- set gRippleSize = #large
- else --not enough RAM for the big ripple
- if totalRAM >= 6000 then
- preloadCast 2453, 2472
- set gRippleSize = #small
- else --not enough RAM for the small ripple; forget it for now…
- return #lowRAM
- EXIT
- end if
- end if
-
- return #OK
-
- end grabberInit
-
- on ripple
- --OK, this one's based on flipping a series of mask castmembers
- -- (1-bit shapes) into the active cast position to outline the distortion..
- global oGrabber, gLastRipple, gRippleSize, gOriginPoint
-
- if the ticks < (gLastRipple + 3*60) then EXIT
-
- if voidP( gRippleSize ) then -- not objectP( oGrabber ) then
- set rippleStatus = grabberInit()
- PUT "rippleStatus = "& rippleStatus
- if rippleStatus <> #OK then EXIT --something's gone wrong with init..
- end if
-
- set rippleSprite = 37
- puppetSprite rippleSprite, TRUE
- set the ink of sprite rippleSprite = 9
-
- --Use the Grabber object to "ripple" a valid region of the screen (in the main view-window)
- -- This should display BEHIND the headgear..
-
- --if there's RAM aplenty, set grab-region and mask-cast accordingly..
- -- NOTE that this could be even faster with a series of RAM-resident PICTURE objects..
- if gRippleSize = #small then
- set firstCastPos = 2453
- set lastCastPos = 2471
- set grabWidth = 96
- set grabHeight = 96
- set rippleTempo = 2
- else
- set firstCastPos = 2428
- set lastCastPos = 2450
- set grabWidth = 160
- set grabHeight = 170
- set rippleTempo = 1
- end if
-
- --Coords are monitor/global? I may need to reckon these based on current monitor dimensions..
- set clipRegion = rect( the stageLeft + 112, the stageTop + 80, the stageLeft + 534, the stageTop + 356)
- -- PUT "<i> clipRegion = "& clipRegion
- --Set offsets into region (random location within valid area)
- set leftOffset = random(the right of clipRegion - the left of clipRegion - (grabWidth + 2))
- set leftEdge = the left of clipRegion + leftOffset
-
- set topOffset = random( the bottom of clipRegion - the top of clipRegion - (grabWidth - 2))
- set topEdge = the top of clipRegion + topOffset
-
- -- PUT "<i>screen coords: leftEdge = "& leftEdge &", topEdge = "& topEdge
- -- set rippleClip = oGrabber(mGetHandle,leftEdge,topEdge,leftEdge+grabWidth,topEdge+grabHeight)
- set errCode = ScreenToClipboard( leftEdge, topEdge,leftEdge+grabWidth,topEdge+grabHeight )
-
- -- if not pictureP( rippleClip ) then
- if errCode = "OK" then
- ALERT "errcode = "& errCode
- EXIT
- end if
-
- --OK, now shift the bubble in the viewing area.., adjusting for stage coords vs. monitor coords..
- set leftEdge = leftEdge - the stageLeft
- set topEdge = topEdge - the stageTop
- -- PUT "<i>stage coords: leftEdge = "& leftEdge &", topEdge = "& topEdge
-
- set the loc of sprite rippleSprite = point(leftEdge + (grabWidth/2), topEdge + (grabHeight/2))
- -- PUT "<i> the loc of sprite rippleSprite = "& the loc of sprite rippleSprite
- set the loc of sprite rippleSprite = the loc of sprite rippleSprite + point(1,1)
- -- PUT "<i> the loc of sprite rippleSprite = "& the loc of sprite rippleSprite
- -- set the picture of cast firstCastPos to rippleClip
- pasteClipboardInto member firstCastPos
- set the castNum of sprite rippleSprite = firstCastPos
-
- set newPos = firstCastPos + 2
- updateStage
-
- repeat while newPos <= lastCastPos
- --a series of (1-bit) cast which will outline the same grabbed picture
- --set the castNum of sprite rippleSprite = newFrame
- --try 'move cast from#, to#' instead..
- --PUT "."
- wait rippleTempo
- move cast (newPos - 2), newPos
- set the castNum of sprite rippleSprite = newPos
- set newPos = newPos + 2
- updateStage
- end repeat
-
- move cast lastCastPos, firstCastPos
- set the loc of sprite rippleSprite = point(-1000,-1000) + gOriginPoint
-
- set gLastRipple = the ticks
-
- end ripple
-